<template>
  <div class="Login-Page">
    <div class="panel panel-primary">
      <div class="panel-heading">
        <h4 class="panel-title">登录</h4>
      </div>
      <div class="panel-body">
        <div v-show="errorMessage" class="alert alert-danger">{{errorMessage}}
          <button @click="errorMessage=null" class="close">&times;</button>
        </div>
        <el-form :model="loginForm" label-width="60px">
          <el-form-item label="登录名">
            <el-input v-validate="'required'" name="login" v-model="loginForm.login"></el-input>
            <span >{{ errors.first('login') }}</span>
          </el-form-item>
          <el-form-item label="密码">
            <el-input v-validate="'required'"  name="password" v-model="loginForm.password"></el-input>
            <span >{{ errors.first('password') }}</span>
          </el-form-item>
        </el-form>
        <div class="row">
          <div class="col-xs-4 col-xs-offset-6">
            <button @click="doLogin()" type="button" class="btn btn-primary btn-block">登录</button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script >
  export default {
    name: 'Login-Page',
    data () {
      return {
        loginForm: {},
        errorMessage: null
      }
    },
    methods: {
      doLogin () {
        this.$validator.validateAll()
          .then(()=>  {
            console.log('正确')
        }).catch (err => {
      })
      }
    }
  }
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .Login-Page {
    width: 320px;
    margin: 60px auto;
  }
</style>
